{* $Id$ *}
{include_core file="admin/lib/header.html" title="用户展示"}
<div class="page-header border-bottom clearfix">
    <h2 class="left">app版本管理<span>在这里你可以查看客户端版本信息</span></h2>
    <a href='{AnUrl("version/admin/add")}' class="btn btn-success btn-sm right"><i class="icon-add"></i>发布新版</a>
</div>
<!--start:列表-->
<div class="list-table-filters">
    <p>
        <span class="label label-info">平台</span>
        <a href='{AnUrl("version/admin?{URLTracker::set("type", 0)}")}' {if $type== 0} class="label label-primary"
           {else} class="label label-default" {/if}>全部</a>
        {foreach version_config::$app_type_list as $k => $v}
        <a href='{AnUrl("version/admin?{URLTracker::set("type", $k)}")}' {if $type== $k} class="label label-primary"
           {else} class="label label-default" {/if}>{$v}</a>
        {/foreach}
    </p>
    <p>
        <span class="label label-info">类型</span>
        <a href='{AnUrl("version/admin?{URLTracker::set("res_name", "")}")}' {if $res_name=== ''} class="label
        label-primary"
        {else} class="label label-default" {/if}>全部</a>
        {foreach version_config::$app_res_list as $k => $v}
        <a href='{AnUrl("version/admin?{URLTracker::set("res_name", $k)}")}' {if $res_name=== $k}
           class="label label-primary"
           {else} class="label label-default" {/if}>{$v}</a>
        {/foreach}
    </p>
</div>
<table class="list-table">
    <thead>
    <tr>
        <th style="width:60px;">ID</th>
        <th>平台</th>
        <th>类型</th>
        <th style="width:60px;">版本号</th>
        <th style="width:60px;">下载链接</th>
        <th style="min-width:300px;">描述</th>
        <th style="width:130px;">发布时间</th>
        <th style="width:60px;">操作</th>
    </tr>
    </thead>
    <tbody>
    {foreach $list as $k=>$v}
    <tr id="dataList{$v.id}">
        <td>{$v.id}</td>
        <td><img width="60" height="60" src="/images/icon/{version_config::$app_type_list[$v.type]}.png"/></td>
        <td><img width="60" height="60" src="/images/icon/{$v.res_name}_launcher.png"/></td>
        <td>{$v.version_no}</td>
        <td style="width:250px;"><a href="{$v.link}">{$v.link}</a></td>
        <td style="width:350px">{$v.txt_desc}</td>
        <td>{$v.update_time}</td>
        <td class="txtcenter">
            <a href="{AnUrl(" version/admin/edit?id={$v.id}&type={$v.type}")}" class="btn btn-info btn-xs"><i
                class="icon-edit icon-white"></i>编辑</a>

            {*<a class="deleteOne btn btn-mini btn-danger" href="{AnUrl(" version/admin/delete","?id={$v.id}&status={$status}")}">删除</a>
            *}
        </td>
    </tr>
    {foreachelse}
    <tr>
        <td colspan="9">暂无相关信息</td>
    </tr>
    {/foreach}
    </tbody>
    </tbody>
    {if $status == 1}
    <tfoot>
    <tr>
        <td><input type="checkbox" class="selectAll"></td>
        <td colspan="6"><a href="{AnUrl(" user/admin/delete")}" class="btn btn-danger btn-xs deleteAll">批量禁用</a></td>
    </tr>
    </tfoot>
    {/if}
</table>
<script type="text/javascript">

    $(function () {

        // 将制定的元素设置为可是区域居中
        function center_format(obj) {
            // 获取可是窗口的宽度
            var winWidth = $(window).width();
            var winHeight = $(window).height();

            // 计算窗体本身的宽和高
            var objWidth = obj.width();
            var objHeight = obj.height();

            // 设置窗体的位置
            obj.css('position', 'fixed');
            // 计算left和top值
            var objLeft = (winWidth - objWidth) / 2;
            var objTop = (winHeight - objHeight) / 3; // 如果除以2感觉不垂直居中
            obj.css('left', objLeft + 'px');
            obj.css('top', objTop + 'px');

        }

        // 高级搜索
        $('.js_advanced').click(function (e) {
            e.preventDefault();
            var thisObj = $(this);
            var outBox = thisObj.closest('form');
            if (thisObj.hasClass('js_isOpen')) {
                thisObj.removeClass('js_isOpen open');
                outBox.find('input').show();
                outBox.find('button').show();
                $('.js_advancedForm').hide();
            } else {
                thisObj.addClass('js_isOpen open');
                outBox.find('input').hide();
                outBox.find('button').hide();
                $('.js_advancedForm').show();
            }
        });

        // 查看子经销商
        $('.js_showSecondDealer').click(function () {
            // 获取此一级经销商的id
            var $url = $(this).attr('url');
            var th = $(this);
            // 发送ajax查询子经销商
            $.ajax({
                url: $url,
                type: "get",
                dataType: 'json',
                success: function (res) {
                    if (res != 'no') {
                        var infoList = res;
                        $('.float-bg').show();
                        var list = $('.js_secondDealerList').clone(true, true);
                        list.find('.js_dealerTitle').html(th.parents('tr').find('td.js_userName').html() + '的子经销商信息');
                        $('body').append(list);

                        // 设置弹窗的位置
                        center_format(list);
                        list.show();

                        // 说明 存在二级经销商
                        for (var i in infoList) {
                            var info = $('<tr><td style="width:200px;text-align:center;border:1px solid #ccc">' + infoList[i]["user_name"] + '</td><td style="width:200px;text-align:center;border:1px solid #ccc">' + infoList[i]["mobile"] + '</td></tr>');
                            list.find('.js_expressTable').append(info);
                        }

                        list.find('.js_closeDealerList').click(function () {
                            list.hide();
                            list.remove();
                            $('.float-bg').hide();
                        });

                    } else {
                        alert('此经销商没有二级经销商!');
                    }
                }
            });

            return false;
        });

    });

</script>
<div class="float-confirm js_secondDealerList"
     style="z-index: 20000;display: none; width:auto; height:auto; margin:0px; position : fixed;">
    <div class="float-confirm-con" style="margin:0px 0px;">
        <a class="icon-close js_closeDealerList" href="javascript:void(0);">关闭</a>
        <p style="font-size:18px;color:#23a18b;" class="js_dealerTitle">子经销商信息</p>
        <div style="width:auto;height:1px;background:#CCC;margin-bottom:20px;"></div>
        <div style="width:500px;max-height:400px;over-flow:hidden;margin-bottom:15px;">
            <table style="line-height:50px;border:1px solid #ccc;margin:0 auto;" class="js_expressTable">
                <tr>
                    <th style="width:200px;text-align:center;border:1px solid #ccc">用户名</th>
                    <th style="width:200px;text-align:center;border:1px solid #ccc">手机号码</th>
                </tr>

            </table>
            <table style="line-height:50px;display:none;width:400px;line-height:24px;" class="js_refundTable">
            </table>
        </div>
        <div style="width:auto;height:1px;background:#CCC;margin-bottom:20px;"></div>
    </div>
</div>
<div class="float-bg" style="z-index: 19999; display: none"></div>
{include_core file="admin/lib/pager.html"}
<!--end:列表-->
{load_js file='zclip/jquery.zclip.min.js'}
{load_js file='zclip/ZeroClipboard.js'}
{include_core file="admin/lib/footer.html"}